package com.yoda.mall.mysql.api;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yoda.mall.api.OrderReturnReasonApi;
import com.yoda.mall.model.entity.oms.OrderReturnReason;
import com.yoda.mall.model.entity.sms.HomeAdvertise;
import com.yoda.mall.mysql.mapper.OrderReturnReasonMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@DubboService
public class OrderReturnReasonApiImpl implements OrderReturnReasonApi {
    @Autowired
    private OrderReturnReasonMapper orderReturnReasonMapper;

    @Override
    public void createOrderReturnReason(OrderReturnReason orderReturnReason) {
        orderReturnReasonMapper.insert(orderReturnReason);
    }

    @Override
    public void deleteOrderReturnReasonByIds(List<Long> ids) {
        orderReturnReasonMapper.deleteBatchIds(ids);
    }

    @Override
    public Page<OrderReturnReason> getOrderReturnReasonListPage(Integer pageNum, Integer pageSize) {
        Page<OrderReturnReason> page = new Page<>(pageNum, pageSize);
        return orderReturnReasonMapper.selectPage(page, null);
    }

    @Override
    public void updateOrderReturnReasonStatusByIds(List<Long> ids, Integer status) {
        UpdateWrapper<OrderReturnReason> uw = new UpdateWrapper<>();
        uw.set("status",status).in("id",ids);
        orderReturnReasonMapper.update(null,uw);
    }

    @Override
    public void updateOrderReturnReason(OrderReturnReason orderReturnReason) {
        orderReturnReasonMapper.updateById(orderReturnReason);
    }

    @Override
    public OrderReturnReason getOrderReturnReasonById(Long id) {
        return orderReturnReasonMapper.selectById(id);
    }
}
